package com.sw.example.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.sw.example.utils.FileUtils;
import com.sw.example.utils.JsonUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import static com.alibaba.fastjson.parser.Feature.AutoCloseSource;

@Component
public class ProcessRecord {

    public static String filePath =  System.getProperty("user.dir")
            + FileUtils.FILE_SEPARATOR
            + "processRecord.json";

    private String title;
    private String desc;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void loadData() {
        String jsonText = JsonUtils.readJson(filePath);
        BeanUtils.copyProperties(JSONObject.parseObject(jsonText,ProcessRecord.class),
                this);
    }
}
